package com.example.h1nson.realphotography.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.h1nson.realphotography.R;

import java.util.List;
import java.util.Map;

/**
 * Created by H1nson on 2016/6/2.
 */
public class SearchAdapter extends BaseAdapter {
    private Context mContext;
    private String[] str = {"人名","地名"};

    public SearchAdapter(Context pContext) {
        this.mContext = pContext;
    }

    @Override
    public int getCount() {
        return str.length;
    }

    @Override
    public Object getItem(int position) {
        return str[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    /**
     * 下面是重要代码
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater _LayoutInflater= LayoutInflater.from(mContext);
        convertView=_LayoutInflater.inflate(R.layout.spinner_item, null);
        if(convertView!=null)
        {
            TextView _TextView1=(TextView)convertView.findViewById(R.id.spinnerText);
            _TextView1.setText(str[position]);
        }
        return convertView;
    }
}